﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoBackupDatabase.DBConection;
using System.Data;
using System.Data.SqlClient;
using AutoBackupDatabase.ENT;

namespace AutoBackupDatabase.DAL
{
    public class WAGEDAL
    {
        private DbConnection conn;

        /// <constructor>
        /// Constructor UserDAO
        /// </constructor>
        public WAGEDAL()
        {
            conn = new DbConnection();
        }


        public List<WAGEENT> GET_WAGE_ALL()
        {
            string query = string.Format("exec GET_WAGE_ALL ");
            DataTable ds = conn.executeGetQuery(query);
            List<WAGEENT> List = new List<WAGEENT>();
            foreach (DataRow item in ds.Rows)
            {
                WAGEENT WAGE = new WAGEENT();
                WAGE.WAGEID =int.Parse( item["WAGEID"].ToString());
                WAGE.WAGENAME = item["WAGENAME"].ToString();
                WAGE.DEPARTMENTID = item["DEPARTMENTID"].ToString();
                WAGE.PRICE =float.Parse( item["WAGENAME"].ToString());
                WAGE.DEPARTMENTNAME = item["DEPARTMENTNAME"].ToString();
                List.Add(WAGE);
            }

            return List;
        }
        public bool INSERTWAGE(WAGEENT ent)
        {
            string query = "exec  INSERTWAGE @WAGEID,@WAGENAME";
            SqlParameter[] sqlParameters = new SqlParameter[4];
            sqlParameters[0] = new SqlParameter("@WAGEID", SqlDbType.Int);
            sqlParameters[0].Value = Convert.ToString(ent.WAGEID);
            sqlParameters[1] = new SqlParameter("@WAGENAME", SqlDbType.NVarChar);
            sqlParameters[1].Value = Convert.ToString(ent.WAGENAME);
            sqlParameters[2] = new SqlParameter("@PRICE", SqlDbType.Float);
            sqlParameters[2].Value = Convert.ToString(ent.PRICE);
            sqlParameters[3] = new SqlParameter("@DEPARTMENTID", SqlDbType.NVarChar);
            sqlParameters[3].Value = Convert.ToString(ent.DEPARTMENTID);
            return conn.executeInsertQuery(query, sqlParameters);
        }
        public bool UPDATEWAREBYWAGEID(WAGEENT ent)
        {
            string query = "exec  UPDATEWAREBYWAGEID @WAGEID,@WAGENAME";
            SqlParameter[] sqlParameters = new SqlParameter[3];
            sqlParameters[0] = new SqlParameter("@WAGEID", SqlDbType.Int);
            sqlParameters[0].Value = Convert.ToString(ent.WAGEID);
            sqlParameters[1] = new SqlParameter("@WAGENAME", SqlDbType.NVarChar);
            sqlParameters[1].Value = Convert.ToString(ent.WAGENAME);
            sqlParameters[2] = new SqlParameter("@PRICE", SqlDbType.Float);
            sqlParameters[2].Value = Convert.ToString(ent.PRICE);
           
            return conn.executeUpdateQuery(query, sqlParameters);
        }
        public bool DELTELEWAREBYWAGEID(WAGEENT ent)
        {
            string query = "exec  DELTELEWAREBYWAGEID @WAGEID";
            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0] = new SqlParameter("@WAGEID", SqlDbType.VarChar);
            sqlParameters[0].Value = Convert.ToString(ent.WAGEID);
            return conn.executeDeleteQuery(query, sqlParameters);
        }
    }
}
